LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-12-2012, 07:55 AM   #1
bashari
LQ Newbie
 
Registered: Sep 2012
Posts: 3

Rep: Reputation: Disabled
How to remove ^L control characters from text files?


Hi All,

When i try to edit the file i m getting this symbol : ^L

its related to clear the screen and redraw so its not letting me to grep any pattern .

1. I want to remove this Symbol : ^L

Thanks in advance.

Regards
Basha G
 
Old 09-12-2012, 08:29 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Hi and welcome to LinuxQuestions!

Ctrl-L is a hidden control character that stats for Form Feed or New Paper sheet. You can find it in the ASCII table at position 12, or better:
Code:
Dec  Hex  Oct  Char  Description
12   C    014  FF    NP Form Feed, new page
You can reproduce it in a terminal using this sequence of keystrokes
Code:
Ctrl-V Ctrl-L
where the first Ctrl-V summons the shell to display a control character. To remove it from a text file, you can either use this sequence of keystrokes or his octal/hex/decimal code taken from the ASCII table.

For example using sed you can do something like this (by typing Ctrl-V and Ctrl-L):
Code:
sed 's/^L//' file
or by means of the octal code:
Code:
sed 's/\o14//' file
Take in mind that to actually change the content of a file using sed, you have to use the -i option. Without -i the output is sent to the terminal (standard output) which is useful for testing the command until it gives the desired result. Hope this helps.
 
1 members found this post helpful.
Old 09-12-2012, 11:36 AM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
To be more specific, ^L is the caret notation for that non-printing ascii character.

tr is usually the most efficient solution for simple character removal jobs, although you have to work through at temporary file to do it.

Code:
tr -d '\014' <infile.txt >outfile.txt
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to remove the first three characters in the name of a ton of files... ooagentbender Linux - Newbie 17 10-04-2013 02:02 PM
Supressing control characters in GTK+ based GUI's text area display iamck25 Linux - Newbie 0 06-13-2012 03:54 PM
Rename all files in dir to remove first nine characters zappadragon Linux - Newbie 4 11-13-2011 06:00 AM
Viewing control characters in a text file dmorse Linux - General 2 01-06-2007 11:10 PM
Clearing control characters from a text file LinuxLala Linux - General 1 04-07-2006 06:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration